export default class Compile {
  constructor(el, vue) {
    this.$vue = vue;
    console.log(el, "e;");
    this.$el = document.querySelector("#app");
    if (this.$el) {
      let fragment = this.nodeToFragment(this.$el);
      this.compile(fragment);
    }
  }
  nodeToFragment(node) {
    let fragment = document.createDocumentFragment();
    var childNode;
    while ((childNode = node.firstChild)) {
      fragment.appendChild(childNode);
    }

    return fragment;
  }
  compile(el) {
    let childNodes = el.childNodes;
    let self = this;
    childNodes.forEach((node) => {
      if (node.nodeType == 1) {
        self.compileElement(node);
      } else if (node.nodeType == 3) {
        self.compileText(node);
      }
    });
    console.log(el, "el");
  }
  compileText(node) {
    console.log(node, "compileText");
  }
  compileElement(node) {
    let attr = node.attributes;
    [...attr].forEach((node) => {
      let name = node.name;
      let value = node.value;
      let dir = name.substring(2);
      if (name.indexOf("v-") == 0) {
            if(dir=='if'){
                
            }else if(dir=='modle'){
                
            }
      }
    });
  }
}
